package com.kgcx.organization.controller;

import com.kgcx.common.bean.RequestData;
import com.kgcx.common.bean.ReturnData;
import com.kgcx.common.controller.BaseController;
import com.kgcx.organization.domain.Training;
import com.kgcx.organization.service.TrainingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(description = "驾驶员培训", tags = "驾驶员培训接口")
@RestController
@RequestMapping("driverTraining")
public class TrainingController extends BaseController {
    @Autowired
    private TrainingService trainingService;
    @ApiOperation(value = "新增驾驶员培训", httpMethod = "POST", notes = "驾驶员培训接口")
    @PostMapping("addDriverTraining")
    public ReturnData<?> addDriverTraining(@RequestBody Training training) {
    		trainingService.insertTraining(training);
        return new ReturnData();
    }

    /**
     * 专给监管平台提供查询
     */
    @ApiOperation(value = "监管平台查询驾驶员培训", httpMethod = "GET", notes = "这是用来给监管平台查询驾驶员培训的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "kid", value = "主键ID", required = false, paramType = "query", dataType = "String", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "licenseId", value = "驾驶证号", required = false, paramType = "query", dataType = "String", dataTypeClass = Long.class)
    })
    @GetMapping("queryTrainingWithPage")
    public ReturnData<List<Training>> queryTrainingWithPage() {
        RequestData requestData = this.getRequestData();
        List<Training> trainings = trainingService.queryTrainingWithPage(requestData);
        return new ReturnData<>(trainings);
    }

    /**
     * 驾驶员培训查询
     */
    @ApiOperation(value = "查询驾驶员培训", httpMethod = "GET", notes = "这是用来查询驾驶员培训的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "kid", value = "主键ID", required = false, paramType = "query", dataType = "String", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "licenseId", value = "驾驶证号", required = false, paramType = "query", dataType = "String", dataTypeClass = Long.class)
    })
    @GetMapping("queryWithPage")
    public ReturnData<List<Training>> queryWithPage() {
        RequestData requestData = this.getRequestData();
        List<Training> trainings = trainingService.queryWithPage(requestData);
        return new ReturnData<>(trainings);
    }
}
